import { reactive } from 'vue';
import { sliceTreeByKey } from '@/utils/helper/treeHelper';
import { useSystemStoreWidthOut } from '@/store/modules/system';
interface DeptLoader {
  deptNames: string[];
}
export const useDept = ({ deptNames }: DeptLoader) => {
  const deptMap = reactive<Recordable>({});
  const systemStore = useSystemStoreWidthOut();

  const depts = systemStore.getDeptTree;
  deptNames.forEach((deptName) => {
    const deptList = sliceTreeByKey({ tree: depts, sliceKey: 'deptName', sliceValue: deptName });
    deptMap[deptName] = deptList || [];
  });
  return {
    deptMap,
  };
};
